<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script>
        'use strict';
        /*
        function Student(name){
            this.name = name;

        }

        //给student新增一个方法
        Student.prototype.hello = function (){
            alert('Hello')
        };
        */


        //ES6之后 =============
        //定义一个学生类
        class Student{
            constructor(name) {
                this.name = name;
            }

            hello(){
                alert('Hello');
            }
        }
        //对象
        var xiaoming = new Student("小明");

        //继承
        class xiaoStudent extends Student{
            constructor(name,grade) {
                super(name);
                this.grade = grade;
            }

            myGrade(){
                alert("我是一名小学生");
            }
        }
        //对象
        var xiaohong = new xiaoStudent("小红","95");
    </script>


</head>
<body>

</body>
</html>